<Search @bind-Value="@searchKey" Placeholder="Search.." />
<Divider Text="Default search (case sensitive)"></Divider>
<Tree ShowIcon SearchValue="@searchKey"
      DataSource="games"
      TitleExpression="x => ((GameElementGroup)x.DataItem).Text"
      ChildrenExpression="x => ((GameElementGroup)x.DataItem).Items"
      IconExpression="x => ((GameElementGroup)x.DataItem).Icon"></Tree>
<Divider Text="Custom search (Ignore case)"></Divider>
<Tree ShowIcon SearchValue="@searchKey"
      DataSource="games"
      TitleExpression="x => ((GameElementGroup)x.DataItem).Text"
      ChildrenExpression="x => ((GameElementGroup)x.DataItem).Items"
      IconExpression="x => ((GameElementGroup)x.DataItem).Icon"
      SearchExpression="x=> ((GameElementGroup)x.DataItem).Text.ToLower().Contains(searchKey.ToLower())"></Tree>

@code{
    string searchKey;

    List<GameElementGroup> games = new List<GameElementGroup>()
{
        new GameElementGroup()
        {
            Text="XBox",
            Icon="windows",
            Items=new List<GameElementGroup>()
{
                new GameElementGroup(){
                    Text="Halo" ,
                    Items = new List<GameElementGroup>(){
                        new GameElementGroup(){Text="Halo1" },
                        new GameElementGroup(){Text="Halo2" },
                        new GameElementGroup(){Text="Halo3" },
                        new GameElementGroup(){Text="Halo4" },
                        new GameElementGroup(){Text="Halo:ODST" },
                        new GameElementGroup(){Text="Halo:REACH" },
                    },
                },
                new GameElementGroup(){Text="Gears of War"},
                new GameElementGroup(){Text="Forza Motosport"},
            }
        },
                new GameElementGroup()
        {
            Text="PlayStation",
            Icon="desktop",
            Items=new List<GameElementGroup>()
{
                new GameElementGroup(){Text="Uncharted" },
                new GameElementGroup(){Text="God Of War" },
                new GameElementGroup(){Text="The Order:1886" },
            }
        },
                new GameElementGroup()
        {
            Text="Switch",
            Icon="mobile",
            Items=new List<GameElementGroup>()
{
                new GameElementGroup(){Text="Super Mario Bros"},
                new GameElementGroup(){Text="The Legend of Zelda"},
            }
        }
    };

    private class GameElementGroup
    {
        public string Text { get; set; }

        public string Icon { get; set; }

        public List<GameElementGroup> Items { get; set; }

    }

}


